import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class StringExtractor {
    public static void main(String[] args) {
        String filePath = "source.txt"; // 源文件路径
        extractStringsFromFile(filePath);
    }

    public static void extractStringsFromFile(String filePath) {
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            StringBuilder currentString = new StringBuilder();
            boolean insideString = false;
            boolean escaping = false;

            int charCode;
            while ((charCode = reader.read()) != -1) {
                char ch = (char) charCode;

                if (insideString) {
                    if (escaping) {
                        // 处理转义字符
                        if (ch == 'n') {
                            currentString.append('\n');
                        } else if (ch == 't') {
                            currentString.append('\t');
                        } else if (ch == '"') {
                            currentString.append('"');
                        } else if (ch == '\\') {
                            currentString.append('\\');
                        } else {
                            // 如果是其他字符，直接追加
                            currentString.append(ch);
                        }
                        escaping = false;
                    } else if (ch == '\\') {
                        // 遇到反斜杠，进入转义字符处理状态
                        escaping = true;
                    } else if (ch == '"') {
                        // 遇到另一个双引号，结束当前字符串处理
                        System.out.println(currentString.toString());
                        currentString.setLength(0); // 清空当前字符串
                        insideString = false;
                    } else {
                        // 普通字符，直接追加
                        currentString.append(ch);
                    }
                } else if (ch == '"') {
                    // 遇到双引号，进入字符串处理状态
                    insideString = true;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}